\chapter{JBoss Installation}

\section{scope}
In here we are about to explain very briefly how to install JBoss application server over Debian-based enviorment.
If you're using others operative systems we recomand to check the online documentation at: \url{http://www.jboss.org/developer}.

\section{Debian-Based Installation}
We recomend to install JBoss from repository, so all you need to do is to open a console windows and type the following command:
\begin{center}
 \emph{apt-get install jbossas5}
\end{center}

From now on, we assume that JBOSS-HOME is the path pointing to jbossas folder, in our case to /usr/share/jbossas5.
All you have to do now for running the server is to get to this location: 
\begin{center}
 \emph{JBOSS\_HOME/bin}
\end{center}

and give:

\begin{center}
 \emph{./run.sh}
\end{center}

For more information look at: 

\begin{center}
\url{http://wiki.debian.org/JBossPackaging}.                               
\end{center}



If you don't want to install it from repo, just download the correct version at: 

\begin{center}
 \url{http://www.jboss.org/jbossas/downloads/} .
\end{center}

\section{MySQL installation}

First of all you need to install MySQL server and client, if you don't know how we recomand to install them from repository (UNIX):
\begin{center}
 \begin{itemize}
  \item \emph{apt-get install mysql-client}
  \item \emph{apt-get install mysql-server}
 \end{itemize}
\end{center}

\section{Configure with MySQL}

In order to configure JBoss with MySQL, you need to download MySQL connector. You get get it from 

\begin{center}
 \url{http://www.mysql.com/downloads/connector/j/}.
\end{center}

Then you must follow the below procedure:

\begin{enumerate}
 \item unzip the connector just downloaded into JBOSS-HOME/server/default/deploy folder
 \item create a data source file and name it like this: 'here-a-name'-ds.xml 
 \item in the file you've just created put the following code where in the user-name tag you must put the DBMS user with priviledge on swimv2 database and in the password tag the corrsponding password.
\end{enumerate}
\lstset{language=XML}
\begin{lstlisting}
<datasources>
  <local-tx-datasource>
    <jndi-name>swimv2</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/swimv2</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>UtenteMySQL</user-name>
    <password>******</password>
    <exception-sorter-class-name>
      org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
    </exception-sorter-class-name>
    <metadata>
      <type-mapping>mySQL</type-mapping>
    </metadata>
  </local-tx-datasource>
</datasources>
\end{lstlisting}
 
Your JBoss is now configured, what we have to do now is to configure MySQL with the previous settings we made.
To attempt this task, just follow this simple steps:

\begin{enumerate}
 \item Join you DBMS and create a new database: call it swimv2 (you must call it like this! otherwise you have to change the ds file)
 \item if you din't create any new user in your DBMS, your default one is root with the password you set during installation. You can create a new one or just use root, the importat is to correct set the ds file above.
 \item you're done!
\end{enumerate}

\section{Https Feature}
We design our application to run over an HTTPS protocol, so you need to configure your server in order to make it support SSL.
The following steps will guide you througt this:

First of all you need to create a certificate (obviously it would be not a valid one for the browsers, but it works fine to explore the application).
To do this you must have a JDK installed, and give the this command in a terminal:

\begin{center}
 
\textbf{Unix}
\begin{center}
  \emph{\$JAVA\_HOME/keytool -genkey -alias tomcat -keyalg RSA \textbackslash
  -keystore /path/to/my/keystore}
\end{center}


\textbf{windows}
\begin{center}
  \emph{\%JAVA\_HOME\% \textbackslash bin\textbackslash keytool -genkey -alias tomcat -keyalg RSA \textbackslash
  -keystore \textbackslash path \textbackslash to \textbackslash my \textbackslash keystore
  }
  
\end{center}
\end{center}

You can omit the reference to JAVA\_HOME if it is in your PATH system variable.
One you give the command you should follow the steps in the creation and do use always the same password (use changeit for example).

Now just follow these few steps to get started with JBoss and SSL:

\begin{enumerate}

 \item go to \emph{JBOSS-HOME/server/default/deploy/jbossweb.sar/} and open the \emph{server.xml} file.
 \item find in the document: \emph{SSL/TLS Connector}. You are suppose to find somenthing like this:
 \lstset{language=XML}
\begin{lstlisting}
 <-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector 
           port="8443" minSpareThreads="5" maxSpareThreads="75"
           enableLookups="true" disableUploadTimeout="true" 
           acceptCount="100"  maxThreads="200"
           scheme="https" secure="true" SSLEnabled="true"
           keystoreFile="${user.home}/.keystore" keystorePass="changeit"
           clientAuth="false" sslProtocol="TLS"/>
-->
\end{lstlisting}

\item remove the comments and put the path to your key (generated in the first step) in the keystoreFile attribute.

\end{enumerate}

Form more information you can give a look here: \url{http://docs.jboss.org/jbossweb/3.0.x/ssl-howto.html}





